count

 

Count returns the number of agents in a specified agentset, where agentset can be turtles, patches, links, etc. (See with to narrow down a given agentset.) For example, show count turtles would show the total number of turtles in a model, and show count turtles with [color = green] would show the number of green turtles in the model.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the count primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Published NetLogo models that use the count primitive:
 
 
Similar primitives:
mean

Find the mean of a list of values.

Read more
mod

Perform the modulo operation, returning the remainder of two numbers.

Read more
if

Conditionally run a command.

Read more
if-else

execute specific code if a condition is true, otherwise, execute other code

Read more
 
Learn another primitive